<?php
// +----------------------------------------------------------------------
// | zhanshop-mcp / TestMcpClient.php    [ 2025/8/10 17:44 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2025 zhangqiquan All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhangqiquan <768617998@qq.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\console;

use zhanshop\client\AichatClient;
use zhanshop\client\McpClient;
use zhanshop\console\Command;
use zhanshop\console\Input;
use zhanshop\console\Output;

class TestAichatClient extends Command
{
    public function configure()
    {
        $this->setTitle("Aichat聊天测试")->useDatabase();
    }

    public function execute(Input $input, Output $output)
    {
        $mcpClient = new McpClient('http://127.0.0.1:3000/mcp', "123");
        $aichatClient = new AichatClient('http://zhanshop-ollama:11434/v1', "123", 'qwen3:8b');
        $aichatClient->setMcpClient($mcpClient);
        $aichatClient->onMessage(function ($chatClient, $msg){
            echo $msg;
        });
//        $aichatClient->setQuestion("帮我将http://test-cdn.zhanshop.cn/202571/-3281133952.mp4转换成mp3");
//        $aichatClient->send();
        while (true){
            echo "\n";
            $data = $input->input("data", "请输入您的提问");
            $aichatClient->setQuestion($data);
            $aichatClient->send();
        }
    }
}